import { createPinia } from 'pinia'
import piniaPluginPersist from 'pinia-plugin-persistedstate'
import { storeToRefs } from "pinia"
import useUserStore from './userStore'
import useMainStore from './mainStore'

const store = createPinia()

const createStore = (app) => {
    store.use(piniaPluginPersist)
    app.use(store)
    // const modules = import.meta.glob("./*.js", { eager: true })
    // for (const [file, module] of Object.entries(modules)) {
    //     const moduleName = file.replace(/^\.\/(.*?).js$/, '$1')
    //     storeInstance[moduleName] = module.default()
    // }
}

export { createStore, useUserStore, useMainStore, storeToRefs }
